/*
 * @Author: chen haoxuan
 * @Date: 2021-05-25 21:39:22
 * @LastEditTime: 2021-05-25 22:20:46
 */
#include <iostream>
using namespace std;
class Clock
{
public:
    Clock()
    {
        hour = 0;
        minute = 0;
        sec = 0;
    }
    Clock(int h, int m, int s) : hour(h), minute(m), sec(s) {}
    void setAlarm(int hour, int minute, int second);
    void run();
    void show_time();
private:
    int hour;
    int minute;
    int sec;
    int set_hour;       // 指定得 小时
    int set_minute;     // 指定得 分钟
    int set_sec;        // 指定得 秒
};
void Clock::setAlarm(int hour, int minute, int second)
{
    set_hour = hour;
    set_minute = minute;
    set_sec = second;
}
void Clock::run()
{
    for (;;)
    {
        sec++;
        if (sec % 60 == 0)              // 从秒开始计时，每过60s，秒归零 分钟加一
        {
            sec -= 60;
            minute++;
            if (minute % 60 == 0)       // 分钟到60 分钟归零 小时加一
            {
                minute -= 60;
                hour++;
            }
        }
        // 判断 是否到达指定时间，到达后跳出循环
        if (hour == set_hour && minute == set_minute && sec == set_sec) 
        break;
    }
    cout<<"Pink! Pink! Pink! Pick! Pink!"<<endl;
}
void Clock::show_time()
{
    cout<<"Now: "<<hour<<":"<<minute<<":"<<sec<<endl;
}
int main()
{
    Clock c1(7,59,57);
    c1.show_time();
    c1.setAlarm(8,59,57);
    c1.run();
    c1.show_time();
    system("pause");
    return 0;
}
